from apps.orders.models import OrderInfo, OrderGoods
from rest_framework import serializers
from apps.goods.models import SKU


class SkuSerializer(serializers.ModelSerializer):

    class Meta:
        model = SKU
        fields = ['name', 'default_image']

# 获取订单商品
class OrderGoodsSerialzer(serializers.ModelSerializer):
    sku = SkuSerializer()
    class Meta:
        model = OrderGoods
        fields = '__all__'


# 查询订单信息序列化器
class OrderInfoSerializer(serializers.ModelSerializer):
    skus = OrderGoodsSerialzer(many=True)
    class Meta:
        model = OrderInfo
        fields = '__all__'

